<?php
// 连接数据库
$link = mysqli_connect("localhost","root","root","2108");
if(!$link){
    die("连接数据库失败");
}

// echo json_encode("****");
// 接收用户名和密码，后端登录检验
$phone = $_POST['phone'];
$password = $_POST['password'];
// $phone = $_POST['phone'];
// echo $_POST['username'];


// 连接数据库
$sql = "SELECT * FROM `only-users` WHERE `phone` = '$phone'";
// echo json_encode($sql);
$res = mysqli_query($link,$sql);

$row = mysqli_fetch_assoc($res);

if($row){
    if($row['password']===$password){
        $arr = [
            "meta"=>[
                "status"=>0,
                "msg"=>"登陆成功"
            ]
        ];
    }else{
        $arr = [
            "meta"=>[
                "status"=>1,
                "msg"=>"手机号或密码错误"
            ]
        ];
    }
}else{
    $arr = [
        "meta"=>[
            "status"=>2,
            "msg"=>"手机号不存在"
        ]
    ];
}

echo json_encode($arr);

?>